home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
-
- class ListRedirect(object):
- '''
- A utility class for lists of items joined by an operator. ListRedirects with length 1
- are a special case and are considered equivalent to the item instead of a list containing it.
- The reduce function is used for normalizing ListRedirect to the single item (and calling reduce on it recursively)
- '''
- reducable = True
-
- def __getattr__(self, attr):
- if hasattr(self._list, attr):
- return getattr(self._list, attr)
- raise AttributeError, '%s has no such attribute %s' % (repr(self), attr)
-
-
- def __iter__(self):
- for i in self._list:
- yield i
-
-
-
- def reduce(self):
- if self.reducable and len(self._list) == 1:
- singleItem = self._list[0]
- if isinstance(singleItem, ListRedirect):
- return singleItem.reduce()
- return singleItem
- len(self._list) == 1
- return []([ item for item in self._list ])
-
-
-
- def ListPrepend(item, list):
- return [
- item] + list
-
-